package com.shf.dynamodb;

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
import com.amazonaws.services.dynamodbv2.document.GetItemOutcome;
import com.amazonaws.services.dynamodbv2.document.Table;
import com.shf.dynamodb.util.DynamoDBClientUtil;

/**
 * 使用文档接口时，您无需指定data type descriptors；数据类型由数据本身的语义表示。
 * 这些 AWS 开发工具包还提供轻松将 JSON 文档转换为本机 DynamoDB 数据类型（以及从这些数据类型转换）的方法
 * @author songhaifeng
 *
 */
public class DocumentDemo {
	public static void main(String[] args) {

        AmazonDynamoDBClient client = DynamoDBClientUtil.getDynamoclient();
        DynamoDB docClient = new DynamoDB(client);
        
        Table table = docClient.getTable("Music");
        GetItemOutcome outcome = table.getItemOutcome(
                "Artist", "No One You Know", 
                "SongTitle", "Call Me Today");

        int year = outcome.getItem().getInt("Year");
        System.out.println("The song was released in " + year);
       
    }
}
